package com.shqcjd.yunweiyanoperator.util;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * autour: lqm
 * desc: SharePreference的封装
 */

public class PrefUtils {

    public static final String FIRST_LOGIN = "first_login";
    public static final String PREF_NAME = "config";

    //登录
    public static final String USER_ID = "user_id";
    public static final String USER_GUIDE_ID = "user_guide_id";//用于远程指导的用户id 操作端前缀加1 专家端前缀加2
    public static final String USER_CODE = "user_code";
    public static final String USER_NAME = "user_name";
    public static final String PHONE_NUMBER = "phone_number";
    public static final String USER_ICON = "user_icon";
    public static final String TOKEN = "token";
    public static final String USER_TYPE = "user_type";
    public static final String USER_ACCOUNT = "user_account";
    public static final String USER_PWD = "user_pwd";
    public static final String USER_POST_NAME = "user_pn";
    public static final String USER_STATE = "user_state";
    public static final String BUSINESSId = "businessId";
    public static final String BUSINESSNAME = "businessName";
    public static final String APPCODE = "appCode";
    public static final String AGORA_APPID = "agoraAppid";
    public static final String MAINTAININFO = "maintainInfo";
    public static final String DEPARTMENTNAME = "departmentName";
    public static final String ORGANIZATION_TYPE = "organizationType";//组织类型{1:企业,2:个人}
    public static final String UPLOAD_VIDEO_URI = "upladVideoUri";//上传视频页的本地视频地址
    public static final String UPLOAD_VIDEO_PROCESS = "upladVideoProcess";//上传视频页的视频进度
    public static final String LOGIN_BEAN = "login_bean";


    public static boolean getBoolean(Context ctx, String key,
                                     boolean defaultValue) {
        SharedPreferences sp = ctx.getSharedPreferences(PREF_NAME,
                Context.MODE_PRIVATE);
        return sp.getBoolean(key, defaultValue);
    }

    public static void setBoolean(Context ctx, String key, boolean value) {
        SharedPreferences sp = ctx.getSharedPreferences(PREF_NAME,
                Context.MODE_PRIVATE);
        sp.edit().putBoolean(key, value).commit();
    }

    public static String getString(Context ctx, String key, String defaultValue) {
        SharedPreferences sp = ctx.getSharedPreferences(PREF_NAME,
                Context.MODE_PRIVATE);
        return sp.getString(key, defaultValue);
    }

    public static void setString(Context ctx, String key, String value) {
        SharedPreferences sp = ctx.getSharedPreferences(PREF_NAME,
                Context.MODE_PRIVATE);
        sp.edit().putString(key, value).commit();
    }

    public static int getInt(Context ctx, String key, int defaultValue) {
        SharedPreferences sp = ctx.getSharedPreferences(PREF_NAME,
                Context.MODE_PRIVATE);
        return sp.getInt(key, defaultValue);
    }

    public static void setInt(Context ctx, String key, int value) {
        SharedPreferences sp = ctx.getSharedPreferences(PREF_NAME,
                Context.MODE_PRIVATE);
        sp.edit().putInt(key, value).commit();
    }

    public static void clearData(Context ctx, String key) {
        SharedPreferences sp = ctx.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        sp.edit().remove(key).clear().commit();
    }
}
